<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册</title>
		<script src="js/mui.min.js"></script>
		<style>
			html, body{
				height:100%;
				width:100%;
				padding: 0;
				margin: 0;
			}
			
			body{
				background: url(image/u=675629265,2686821793&fm=26&gp=0.jpg);
				background-size:cover;
				background-repeat: no-repeat;
			}
			
			input{
				width: 75%; 
				height:7%; 
				margin-top: 5%; 
				border-radius: 10px;
				background: rgba(255,255,255,0.3); 
				border: 0px;
				padding-left: 5%;
				transition: 0.3s all ease;
			}
			
			input:focus, select:focus{
				box-shadow: rgb(105, 187, 209) 0 0 28px;
				border: 0px;
			}
			
			select{
				width: 80%;
				height:7%;
				margin-top: 5%;
				border-radius: 10px; 
				padding:  0  0  0  5%   ;
				background: rgba(255,255,255,0.3);
				border: 0px;
			}
			
			.container{
				margin: 10% 5% 10% 5%;
				background: rgba(255,255,255,0.2); 
				border-radius: 10px; 
				width: 90%; 
				height: 90%;
				text-align: center;
			}
			
			button{
				width: 80%; 
				height: 7%;
				margin: 10% ; 
				border-radius: 10px;
				background: #1296db;
				animation: move 5s;
			}
			
			p{
				text-align: center;
				color:#554292
			}
			
			a{
				text-decoration: none;
			}

		</style>
	</head>
	<body>
		<div class="container">
			<input type="text" id="account" placeholder="请输入用户名" />
			<input type="password" id="password" placeholder="请输入密码" />
			<input type="password" id="password_confirm" placeholder="请确认密码" />
			<!-- <input type="text" id="phone" placeholder="请输入手机号" /> -->
			<select id="identity">
				<option value="1">学生</option>
				<option value="2">教师</option>
				<option value="3">维修老师</option>
			</select>
			<br>
			<button id="reg">注册</button>
			<p><a href="login.html">已有账号？点我登录</a></p>
		</div>
	</body>
	<script>
		document.getElementById("reg").addEventListener('tap', function(e) {
			var account = document.getElementById('account').value;
			var password = document.getElementById('password').value;
			var password2 = document.getElementById('password_confirm').value;
			// var phone = document.getElementById('phone').value;
			var identity = document.getElementById('identity').value;
			if (account.length === 0 || password.length === 0) {
				alert("请输入完整信息");
				return;
			}
			if (password != password2) {
				alert("密码不一致");
				return;
			}
			mui.ajax({
				url: 'http://192.168.1.104:8080/School/users/regist',
				type: "post",
				async: false,
				data: {
					"userName": account,
					'password': password,
					// 'phone': phone,
					'state': identity
				},
				dataType: "json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8",
				jsonp: "jsoncallback",
				success: function(data) {
					if (data['suc'])
						alert("注册成功, 请进行登录操作");
					else
						alert("注册失败");
				},
				error: function() {
					alert("网络开小差了");
				}
			});
		});
	</script>
</html>
